package Classic150;

import Tree.TreeNode;

public class 对称二叉树 {
    /*
        需要同时判断两组，故应再写一个方法
     */
    public boolean isSymmetric(TreeNode root) {
        return compare(root.left, root.right);
    }

    private boolean compare(TreeNode left, TreeNode right) {
        if (left == null) return right == null;
        else if (right == null || right.val != left.val) return false;
        else return compare(left.left, right.right) && compare(left.right, right.left);
    }
}
